package Java常用类的学习;

import java.util.*;

public class UseCollection {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<String>(Arrays.asList("A", "B", "C", "E")) ;
        String []strArray={"F","G","H","I","J","K"};
        Iterator it;
        collection.addAll(Arrays.asList(strArray));
        Collections.addAll(collection,"L","M","N");
        System.out.println(collection);
        for(it=collection.iterator();it.hasNext();)
            System.out.print(it.next()+" ");
        System.out.println();
        it=collection.iterator();
        it.forEachRemaining((obj)->System.out.print(obj+"-"));
        collection.remove("A");
        it=collection.iterator();
        System.out.println();
        it.forEachRemaining((obj)->System.out.print(obj+">"));
        System.out.println();
        Collection <String> part=new ArrayList<String>(Arrays.asList("B","C","D","E"));
//        保存与part 相同的元素
        collection.retainAll(part);
//        提供了另一种遍历方式
        for(String stt:collection){
            System.out.print(stt+".");
        }
        System.out.println();
//        返回一个数组
        Object [] obj=collection.toArray();
        System.out.println(Arrays.deepToString(obj));
        for(int i=0;i<obj.length;i++)System.out.print(obj[i]+"*");
        System.out.println();
//        一出collection中的所有元素
        collection.removeAll(collection);
        System.out.println(collection.size());
//        lambda 表达式的学习

//        (value)->(value%2)==0;

        }

}
